package my.jbf.firstGame.GAMEDATA;
import android.database.sqlite.*;
import android.content.*;
public class GameDBHelper extends SQLiteOpenHelper
{

	private static final int VERSION=1;
	private static String dbname= GameDBSetting.getGameDBaddress;
	public GameDBHelper(Context context,String address)
	{
		super(context,address,null,VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		// TODO: Implement this method
		
		createMapTable(db);
		createMapData(db);
		createDrawTable(db);
		createDrawData(db);
	}

	private void createDrawData(SQLiteDatabase db)
	{
		// TODO: Implement this method
		ContentValues cv=new ContentValues();
		String id= GameDBSetting.Draw_table._TID;
		String name= GameDBSetting.Draw_table._NAME;
		String up= GameDBSetting.Draw_table._UP;
		String drawbox= GameDBSetting.Draw_table._DRAWBOX;

		cv.put(id,"001");
		cv.put(name,"test_长方形");
		cv.put(up,"0");
		cv.put(drawbox,"m175,100l275,100l275,300l175,300z");
		db.insert(GameDBSetting.tablename.DrawTableName,null,cv);
		cv.clear();
	}

	private void createDrawTable(SQLiteDatabase db)
	{
		
		// TODO: Implement this method
		String strSQL_draw = "create table "
			+ GameDBSetting.tablename.DrawTableName
			+" ("+ GameDBSetting.Draw_table._TID+" integer primary key autoincrement, "
			+ GameDBSetting.Draw_table._UP+" integer, "
			+ GameDBSetting.Draw_table._NAME+" text, "
			+ GameDBSetting.Draw_table._DRAWBOX+" text)";
		db.execSQL(strSQL_draw);
	}

	private void createMapData(SQLiteDatabase db)
	{
		// TODO: Implement this method
		ContentValues cv=new ContentValues();

		cv.clear();
		cv.put(GameDBSetting.Map_table._NAME, "er");
		db.insert(GameDBSetting.tablename.MapTableName, null, cv);
		
	}

	private void createMapTable(SQLiteDatabase db)
	{
		// TODO: Implement this method
		String strSQL="create table if not exists "+ GameDBSetting.tablename.MapTableName
			+ " (" + GameDBSetting.Map_table._TID + " integer primary key autoincrement, "
			+ GameDBSetting.Map_table._NAME + " text, "
			+ GameDBSetting.Map_table._ENEMYNUM + " integer, "
			+ GameDBSetting.Map_table._HAVEEXITDOOR + " boolean, "
			+ GameDBSetting.Map_table._LENGTH + " float, "
			+ GameDBSetting.Map_table._WEIGTH + " float, "
			+ GameDBSetting.Map_table._MAXENEMY + " integer, "
			+ GameDBSetting.Map_table._NUMOFBOSS + " integer) ";
		db.execSQL(strSQL);
	}

	@Override
	public void onUpgrade(SQLiteDatabase p1, int p2, int p3)
	{
		// TODO: Implement this method
	}
	

	
}
